Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Partial Class loginSuccess
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Try
            Dim myConn As New SqlConnection(ConfigurationSettings.AppSettings("cons"))
            Dim sqlUSD As SqlCommand
            myConn.Open()

            sqlUSD = New SqlCommand("insert into tygia (ngay,usd,aud,eur,yen) values (getdate()," & TextBox1.Text & _
                                    "," & TextBox2.Text & ", " & TextBox3.Text & ", " & TextBox4.Text & ")", myConn)
            sqlUSD.ExecuteNonQuery()

            sqlUSD.CommandText = "select top 1 usd from tygia order by idtygia desc"

            Label1.Text = FormatNumber(sqlUSD.ExecuteScalar.ToString, 0, TriState.False, TriState.False, TriState.True)

            sqlUSD.Dispose()

            myConn.Close()
        Catch ex As Exception

        End Try
    End Sub
End Class
